<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加商品</title>
</head>
<body>
<div>
    <input type="text" placeholder="商品名" v-model="product.title">
    <input type="text" placeholder="库存" v-model="product.num">
    <input type="text" placeholder="价格" v-model="product.price">
    <input type="button" value="添加" @click="insert()">
</div>
<!--引入Vue框架-->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!--引入Axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            product:{title:"",num:"",price:""}
        },
        methods:{
            insert(){
                axios.post("/insert",v.product).then(function () {
                    alert("添加完成")
                    location.href="/";
                })
            }
        }
    })
</script>
</body>
</html>